package com.yzs.exam.controller.student;

import com.yzs.exam.common.base.BaseApiController;
import com.yzs.exam.common.base.RestResponse;
import com.yzs.exam.entity.Chapter;
import com.yzs.exam.entity.User;
import com.yzs.exam.service.ChapterService;
import com.yzs.exam.viewmodel.admin.education.ChapterPageRequestVM;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yzs
 * @create 2021-04-27 20:22
 */
@Api(value = "知识点模块", tags = {"知识点接口"})
@RestController(value = "studentChapterController")
@RequestMapping(value = "api/student/chapter/")
public class ChapterController extends BaseApiController {

    private final ChapterService chapterService;

    @Autowired
    public ChapterController(ChapterService chapterService) {
        this.chapterService = chapterService;
    }

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public RestResponse<List<Chapter>> list(){
        User user = getCurrentUser();
        List<Chapter> chapters = chapterService.getChaptersByLevel(user.getUserLevel());
        return RestResponse.ok(chapters);
    }
}
